﻿using System;
using System.ComponentModel;

namespace Kaysite.Model
{
    public static class Extentions
    {
        public static string GetName(this Enum value)
        {
            var fi = value.GetType().GetField(value.ToString());
            if (fi == null)
                return string.Empty;
            var attrs = fi.GetCustomAttributes(typeof (DescriptionAttribute), false) as DescriptionAttribute[];
            return attrs != null && attrs.Length > 0 ? attrs[0].Description : value.ToString();
        }
    }
}
